package com.mapsolute.map24webservices15.clients.axis.wrappers;

import java.awt.Polygon;
import java.util.Hashtable;
import java.util.Enumeration;
import java.util.StringTokenizer;

import com.mapsolute.map24webservices15.clients.axis.stubs.*;

/**
 * The Map24 MapletRemoteControl (MRC) is designed to provide a common interface for "remote controlling" 
 * mapping clients and for data integration ("pushing data"). Some example commands are: 
 * Change the view of the map, display a geometric shape such as a polygon, display an icon or label on the 
 * map to mark a location and many others. For general information on remote controlling mapping clients and 
 * data integration see the MapTP Technical Whitepaper: Remote Controlling Mapping Clients.
 *
 * This class provides a wrapper for parts of the functionality of the Map24 MRC Service.
 */
public class Map24MapletRemoteControlWrapper 
{
	
	public static boolean WAIT_FOR_MRC_RESPONSE= true;

	// ------------------------------------------------------------------------
	//  C o o r d i n a t e 
	// ------------------------------------------------------------------------
	/** 
     * Helper method for instantiating a Coordinate object.
	 * 
	 * @param longitude 	The coordinate's longitude of type float.
	 * @param latitude 	    The coordinate's latitude of type float.
	 * @return coordinate	The coordinate. The coordinate's longitude and latitude are returned as double values.
	 */
	public static Coordinate Coordinate(float longitude, float latitude)
	{
		Coordinate coordinate= new Coordinate();
		coordinate.setLongitude ((double)longitude);
		coordinate.setLatitude  ((double)latitude);
		
		return coordinate;
		
	} // Coordinate
	
	
	/** 
     * Helper method for instantiating a Coordinate object.
	 * 
	 * @param longitude 	The coordinate's longitude of type double.
	 * @param latitude 	    The coordinate's latitude of type double.
	 * @return coordinate	The coordinate.
	 */
	public static Coordinate Coordinate(double longitude, double latitude)
	{
		Coordinate coordinate= new Coordinate();
		coordinate.setLongitude (longitude);
		coordinate.setLatitude  (latitude);
		
		return coordinate;
		
	} // Coordinate
	
	/**
	* Helper method for instantiating a CoordinatesArray object.
	*
	* @param longitudes  A string containing longitudes, separated with a pipe (|) sign.
	* @param latitudes   A string containing latitudes, separated with a pipe (|) sign.
	*/
	public static CoordinatesArray CoordinatesArray(String longitudes, String latitudes)
	{
		CoordinatesArray coordarray= new CoordinatesArray();
		coordarray.setLongitudes (longitudes);
		coordarray.setLatitudes  (latitudes);
		
		return coordarray;
		
	} // Coordinate
	
	// ------------------------------------------------------------------------
	//  C o l o r
	// ------------------------------------------------------------------------
	/** 
     * Helper method for instantiating a Color object.
	 * 
     * The generated Color class (client stub) does only provide a default constructor.
	 * Use this method for easily declaring an instance of type Color.
     * A Color is defined by its red, green and blue values, as well as an alpha value for its transparency. 
     * All values are in range [0..255]. The higher the color value, the lighter is the color shade. 
     * The higher the tranparency value, the more opaque is the color. For example, a transparency value 
     * of 255 means no trancparency.
	 * 
	 * @param red       The red color component.
	 * @param green	The green color component.
	 * @param blue	The blue color component.
	 * @param alpha	The alpha value.
	 * @return color	The object of type Color.
	 */
	public static Color Color(int red, int green, int blue, int alpha)
	{
		Color color= new Color();
		
		color.setAlpha	(alpha);
		color.setRed	(red);
		color.setGreen	(green);
		color.setBlue	(blue);
		
		return color;
		
	} // Color
	
	
	
	// ------------------------------------------------------------------------
	//  P r o p e r t y
	// ------------------------------------------------------------------------
	/** 
	 * Helper method for instantiating a Property object.
	 *
	 * The generated Property class (client stub) does only provide a default constructor.
	 * Use this method for easily declaring an instance of type Property.
	 * A Property object consists of a key-value pair.
	 * 
	 * @param key	The property's key.
	 * @param value	The property's value.
	 * @return prop	The object of type Property.
	 */
	public static MProperty MProperty(String key, String value)
	{
		MProperty prop= new MProperty();
		
		prop.setKey	(key);
		prop.setValue	(value);
		
		return prop;
		
	} // Property
	
	
	// ------------------------------------------------------------------------
	//  C o n t r o l  C o m p o n e n t
 	// ------------------------------------------------------------------------
	/** 
	 * Helper method for setting the visibility of map controls. 
	 * 
	 * Map controls are GUI controls on top of the map such as the toolbar, the map overview window, or the scalebar. 
	 * For further information on map controls see the Map24 MRC ControlComponent User's Guide.
	 * 
	 * @param ctrl 	      The command: "SHOW" shows the component, "HIDE" hides the component.
	 * @param component   The ID of the map control to be controlled.
	 * @param props 	  Optional properties of type Property.
	 * @return cmd	      An instance of XMLCommandWrapper containing the ControlComponent command.
	 */
	public static XMLCommandWrapper ControlComponent(String ctrl, String component, MProperty[] props) throws Exception
	{
		MControlComponent control= new MControlComponent();
		{
			control.setMControl(ComponentControl.fromValue(ctrl));
			control.setComponent(component);
			control.setProperties(props);
		}
		
		XMLCommandWrapper cmd = new XMLCommandWrapper();
		{
			cmd.setControlComponent(control);
		}
		
		return cmd;
		
	} // ControlComponent
		
	
	
	// ------------------------------------------------------------------------
	//  C o n t r o l  M a p  O b j e c t s 
 	// ------------------------------------------------------------------------
	/** 
     * Helper method for setting the visibility of map objects. 
	 * 
	 * @param ctrl 	        The command (SHOW, HIDE, ENABLE or DISABLE).
	 * @param mapobjectids 	The IDs of the map objects to be shown.
	 * @return cmd          An instance of XMLCommandWrapper containing the ControlMapObject command.
	 */
	public static XMLCommandWrapper ControlMapObjects(String ctrl, String[] mapobjectids)
	{
		MControlMapObject control= new MControlMapObject();
		{
			control.setMControl(MControl.fromValue(ctrl));
			control.setMapObjectIDs(mapobjectids);
		}
		
		XMLCommandWrapper cmd = new XMLCommandWrapper();
		{
			cmd.setControlMapObject(control);
		}
		
		return cmd;
		
	} // ControlMapObjects
	
	
	

  
	// ------------------------------------------------------------------------
	//  C o n t r o l  L a y e r s 
 	// ------------------------------------------------------------------------
	/** 
     * Helper method for setting the visibility of custom or Map24 layers.
	 * 
	 * @param ctrl 	      	The command (SHOW, HIDE, ENABLE or DISABLE).
	 * @param layerids 	    The IDs of the layers to be shown/hidden.
	 * @param map24layers 	If true, the controlled layers are Map24 layers. Otherwise, they are custom layers.
	 * @return		        An instance of XMLCommandWrapper containing the ControlLayer command.
	 */
	public static XMLCommandWrapper ControlLayers(String ctrl, String[] layerids, boolean map24layers) throws Exception
	{
		MControlLayer control= new MControlLayer();
		{
			control.setMControl		(MControl.fromValue(ctrl));
			control.setLayerIDs		((layerids == null) ? (new String[0]) : layerids);
			control.setMap24Layers	(map24layers);
			
		}
		
		XMLCommandWrapper cmd = new XMLCommandWrapper();
		{
			cmd.setControlLayer(control);
		}
		
		return cmd;
		
	} // ControlLayers
	
	/**
	* Helper method for setting the visibility of custom layers.
	* 
	* @param ctrl		The command (SHOW, HIDE, ENABLE or DISABLE).
	* @param layerids	The IDs of the layers to be shown/hidden.
	* @return			An instance of XMLCommandWrapper containing the ControlLayer command.
	*/ 
	public static XMLCommandWrapper ControlCustomerLayers(String ctrl, String[] layerids) throws Exception
	{
		return ControlLayers(ctrl, layerids, false);
		
	} // ControlCustomerLayers
	
	/**
	* Helper method for setting the visibility of Map24 layers.
	* 
	* @param ctrl		The command (SHOW, HIDE, ENABLE or DISABLE).
	* @param layerids	The IDs of the layers to be shown/hidden.
	* @return			An instance of XMLCommandWrapper containing the ControlLayer command.
	*/ 
	public static XMLCommandWrapper ControlMap24Layers(String ctrl, String[] layerids) throws Exception
	{
		return ControlLayers(ctrl, layerids, true);
		
	} // ControlMap24Layers
	
	
	// ------------------------------------------------------------------------
	//  S e t M a p V i e w
	// ------------------------------------------------------------------------
	/** 
	 * Helper method for setting the map view.
	 * 
	 * The SetMapView command is used for setting the Map24 session's map view 
	 * regardless of its current state. The size of the new map view is defined by 
	 * the bounding box that contains all defined coordinates and / or map objects.
	 * The map view will be stretched as specified by parameters clwMinimumWidth and 
	 * clwPercentage.
	 * 
	 * @param mapobjectids 		The IDs of map objects to set the map view to.
	 * @param coordinates		The coordinates to set the map view to.
	 * @param clwMinimumWidth  	Minimum width of the map view in meters.
	 * @param clwPercentage		Optionally, you can create a "frame" around the shown map 
	 *                          objects so that they are not shown directly at the borders 
	 *                          of the map view. This is done by increasing the new map view 
	 *                          by the given percentage value in the clwPercentage field.
	 * @return 					An instance of XMLCommandWrapper containing the SetMapView command.
	 */
	public static XMLCommandWrapper SetMapView(String[] 	mapobjectids, 
											   Coordinate[] coordinates, 
											   int 			clwMinimumWidth, 
											   int 			clwPercentage)
	{
		SetMapViewClippingWidth clw= new SetMapViewClippingWidth();
		clw.setMinimumWidth  (clwMinimumWidth);
		clw.setViewPercentage((float)clwPercentage);		
		
		SetMapView setMapView= new SetMapView();
		setMapView.setMapObjectIDs(mapobjectids);
		setMapView.setCoordinates (coordinates);
		
		setMapView.setClippingWidth(clw);
		
		XMLCommandWrapper cmd = new XMLCommandWrapper();
		cmd.setSetMapView(setMapView);
		
		return cmd;
		
	} // SetMapView
	
//	 ------------------------------------------------------------------------
	//  M o d i f y M a p V i e w
	// ------------------------------------------------------------------------
	/** 
	 * Helper method for modifying the current map view.
	 * 
	 * use this method for easily declaring an XMLCommandWrapper with
	 * Command ModifyMapView. The resulting Mapview will cover the objects
	 * and coordinates specified. It will be stretched as specified by
	 * parameters clwMinimumWidth and clwPercentage
	 * 
	 * @param mapobjectids 	The IDs of the MapObjects to be shown
	 * @return cmd
	 */
	public static XMLCommandWrapper ModifyMapView(ModifyMapViewControl Control, int Percentage)
	{
		
		
		ModifyMapView ModifyMapView = new ModifyMapView();
		ModifyMapView.setMControl(Control);
		ModifyMapView.setPercentage(Percentage);
			
		XMLCommandWrapper cmd = new XMLCommandWrapper();
		cmd.setModifyMapView(ModifyMapView);
		
		return cmd;
		
	} // ModifyMapView
	
	
	
//	 ------------------------------------------------------------------------
	//  S e t H o m e V i e w
	// ------------------------------------------------------------------------
	/** 
	 * Helper method for setting the home view.
	 * 
	 * The SetHomwView command is used for setting the Map24 session's home view
	 * The size of the new map view is defined by 
	 * the defined coordinates.
	 * The map view will be stretched as specified by parameters clwMinimumWidth and 
	 * clwPercentage.
	 * 
	 * * @param coordinates		The coordinates to set the map view to.
	 * @param clwMinimumWidth  	Minimum width of the map view in meters.
	 * @param clwPercentage		Optionally, you can create a "frame" around the shown map 
	 *                          objects so that they are not shown directly at the borders 
	 *                          of the map view. This is done by increasing the new map view 
	 *                          by the given percentage value in the clwPercentage field.
	 * @return 					An instance of XMLCommandWrapper containing the SetMapView command.
	 */
	public static XMLCommandWrapper SetHomeView( Coordinate[] coordinates, 
											   int 			clwMinimumWidth, 
											   int 			clwPercentage)
	{
		SetMapViewClippingWidth clw= new SetMapViewClippingWidth();
		clw.setMinimumWidth  (clwMinimumWidth);
		clw.setViewPercentage((float)clwPercentage);		
		
		SetHomeView setHomeView= new SetHomeView();
		setHomeView.setCoordinates (coordinates);
		
		setHomeView.setClippingWidth(clw);
		
		XMLCommandWrapper cmd = new XMLCommandWrapper();
		cmd.setSetHomeView(setHomeView);
		
		return cmd;
		
	} // SetMapView
	
	
	// ------------------------------------------------------------------------
	//  D e c l a r e M a p O b j e c t G r o u p
	// ------------------------------------------------------------------------
	/** 
	 * Helper method for declaring a map object group.
	 * 
	 * @param groupid 	   	The group's key within the Map24 session. The map object IDs 
	 *                     	must refer to existing map objects in the Map24 session. 
	 *                     	This command can also be used to add a map object to an existing 
	 *                     	map object group.
	 * @param mapobjectids 	Contains the IDs of the map objects that should be added to the group. 
	 * 						When creating the map object IDs, it is recommended to put a "0" in 
	 * 					    front of each one-digit number. Example 01, 02, 03,... This has the 
	 * 						advantage that the order of numbers is always correct. For example, 
	 * 					 	if the MapObjectIDs have the structure LOCxx, then they will be 
	 * 						ordered LOC01, LOC02, ... LOC10, LOC11, LOC12, and so on. If the map 
	 * 						object ID of the group itself is part of the map object ID's sequence, 
	 * 						the current contents of the group will be merged with the map objects 
	 * 						declared in the command.
	 * @return 				An instance of XMLCommandWrapper containing the DeclareMapObjectGroup command.
	 */
	public static XMLCommandWrapper DeclareMapObjectGroup(String 	groupid, String[] mapobjectids)
	{
		DeclareMapObjectGroup group= new DeclareMapObjectGroup();
		
		group.setMapObjectGroupID	(groupid);
		group.setMapObjectIDs		(mapobjectids);
		
		XMLCommandWrapper cmd = new XMLCommandWrapper();
		cmd.setDeclareMapObjectGroup(group);
		
		return cmd;
		
	} // DeclareMapObjectGroup

	
	// ------------------------------------------------------------------------
	//  D e c l a r e M a p 2 4 L o c a t i o n
	// ------------------------------------------------------------------------
	/** 
 	 * Helper method for declaring a Map24 Location.
	 *
	 * The DeclareMap24Location command is used for adding Map24 Locations 
	 * to a Map24 session. The Map24 Location's coordinate must be within the
	 * bounds of the map for the Map24 session. Otherwise the command will be 
	 * ignored.
	 * 
	 * @param mapobjectid 	The unique identifier for the Map24 Location.
	 * 						This must be a non-empty string value.
	 * @param coordinate 	The coordinates of the Map24 Location on the map.
	 * @param symbolid 		If the logoURL parameter is not specified, it is possible 
	 * 						to specify the ID of a symbol in an image library. All 
	 * 						image libraries are stored in the resource directory. 
	 * 					 	Each image library contains 10 images For example, the 
	 * 						third image in a library called symMap24_2.gif is specified 
	 * 						with 23 (2 is the number of the image library and 3 is the 
	 * 						number of the image).
	 * @param logourl 		The URL of the logo that represents the Map24 Location on the map.
	 * @param description 	An optional description of the Map24 Location that will be shown
	 * 						in the tooltip. In the mapping clients the tooltip is shown when 
	 * 						moving the mouse pointer over the icon or clicking on it.
	 * @return 				An instance of XMLCommandWrapper containing the DeclareMap24Location command.
	 */
	public static XMLCommandWrapper DeclareMap24Location(String 	mapobjectid, 
														 Coordinate coordinate,
														 int 		symbolid, 
														 String 	logourl, 
														 String 	description)
	{
		DeclareMap24Location location= new DeclareMap24Location();
		location.setMapObjectID (mapobjectid);
		location.setSymbolID 	(symbolid);
		location.setLogoURL    	(logourl);	
		location.setCoordinate  (coordinate);
		location.setDescription	(description);
		
		XMLCommandWrapper cmd = new XMLCommandWrapper();
		cmd.setDeclareMap24Location(location);
		
		return cmd;
		
	} // DeclareMap24Location

	
	
	// ------------------------------------------------------------------------
	//  D e c l a r e M a p 2 4 L a b e l
	// ------------------------------------------------------------------------
	/** 
	 * Helper method for declaring a Map24 Label.
	 *
	 * The DeclareMap24Label command can be used for introducing text-based 
	 * Map24 Labels to a Map24 session. 
	 * 
	 * @param mapobjectid 	Unique identifier of the Map24 Label. 
	 * 						This must be a non-empty string value.
	 * @param coordinate 	The coordinates of the label on the map. 
	 * @param text			The text of the label.
	 * @param inscrColor	The text color of type Color.
	 * @param bgrdColor		The background color of type Color.
	 * @param frameColor	The frame color of type Color.
	 * @param anchor		The Anchor is for specifying the label's position 
	 * 						relative to its coordinate. It must be either of 
	 * 						CENTER, NORTH, NORTHEAST, EAST, SOUTHEAST, SOUTH, 
	 * 						SOUTHWEST, WEST or NORTHWEST.
	 * @param xOffset		The (X,Y)Offsets are only taken into account with an 
	 * 						Anchor not equal to CENTER and provide the possibility 
	 * 						to shift the label pixelwise along its calculated position. 
	 * 						For example, if the Anchor is SOUTH and YOffset is 10 the 
	 * 						upper border of the label is 10 pixels below its longitude/latitude.
	 * @param yOffset		See xOffset.
	 * @return 				An instance of XMLCommandWrapper containing the DeclareMap24Label command.
	 */
	public static XMLCommandWrapper DeclareMap24Label(String 	mapobjectid, 
														 Coordinate coordinate,
														 String[]	text,
														 Color		inscrColor,
														 Color		bgrdColor,
														 Color		frameColor,
														 DeclareMap24LabelAnchor		anchor,
														 int		xOffset,
														 int		yOffset)
	
	
	{
		DeclareMap24Label label= new DeclareMap24Label();
		label.setMapObjectID (mapobjectid);
		label.setCoordinate  (coordinate);
		label.setText(text);
		label.setInscriptionColor(inscrColor);
		label.setBgrdColor(bgrdColor);
		label.setFrameColor(frameColor);
		
		if (anchor==null)
		{
			anchor=DeclareMap24LabelAnchor.fromValue(DeclareMap24LabelAnchor._CENTER);
		}
		
		label.setAnchor(anchor);
		label.setXOffset(xOffset);
		label.setYOffset(yOffset);
		
		
		XMLCommandWrapper cmd = new XMLCommandWrapper();
		cmd.setDeclareMap24Label(label);
		
		return cmd;
		
	} // DeclareMap24Location 2nd version
	
	/** 
 	 * Helper method for declaring a Map24 Address that shows the specified URL on mouse click.
	 *
	 * The DeclareMap24Location command is used for adding Map24 Locations 
	 * to a Map24 session. The Map24 Address's coordinate must be within the
	 * bounds of the map for the Map24 session. Otherwise the command will be 
	 * ignored.
	 * 
	 * @param mapobjectid 	The unique identifier for the Map24 Address.
	 * 						This must be a non-empty string value.
	 * @param coordinate 	The coordinates of the Map24 Address on the map.
	 * @param symbolid 		If the logoURL parameter is not specified, it is possible 
	 * 						to specify the ID of a symbol in an image library. All 
	 * 						image libraries are stored in the resource directory. 
	 * 					 	Each image library contains 10 images For example, the 
	 * 						third image in a library called symMap24_2.gif is specified 
	 * 						with 23 (2 is the number of the image library and 3 is the 
	 * 						number of the image).
	 * @param logourl 		The URL of the logo that represents the Map24 Address on the map.
	 * @param description 	An optional description of the Map24 Address that will be shown
	 * 						in the tooltip. In the mapping clients the tooltip is shown when 
	 * 						moving the mouse pointer over the icon or clicking on it.
	 * @param url			A valid URL. If specified, the mapping clients will display the 
	 * 						Map24 Address in a button style (3D frame). When clicking on the button,
	 * 						the specified URL will be shown in a new frame (targetFrame). 
	 * @param targetFrame	If a URL is given, it will be shown in the specified target frame.
	 * @return 				An instance of XMLCommandWrapper containing the DeclareMap24Location command.
	 */
	public static XMLCommandWrapper DeclareMap24Location(String 	mapobjectid, 
			 Coordinate coordinate,
			 int 		symbolid, 
			 String 	logourl, 
			 String 	description,
			 String     url,
			 String     targetFrame)
{
DeclareMap24Location location= new DeclareMap24Location();
location.setMapObjectID (mapobjectid);
location.setSymbolID 	(symbolid);
location.setLogoURL    	(logourl);	
location.setCoordinate  (coordinate);
location.setDescription	(description);
location.setURL         (url);
location.setTargetFrame (targetFrame);

XMLCommandWrapper cmd = new XMLCommandWrapper();
cmd.setDeclareMap24Location(location);

return cmd;

} // DeclareMap24Location 2nd version

	/** 
 	 * Helper method for declaring a Map24 Address with events.
	 *
	 * The DeclareMap24Location command is used for adding Map24 Locations 
	 * to a Map24 session. The Map24 Address's coordinate must be within the
	 * bounds of the map for the Map24 session. Otherwise the command will be 
	 * ignored.
	 * 
	 * @param mapobjectid 	The unique identifier for the Map24 Address.
	 * 						This must be a non-empty string value.
	 * @param coordinate 	The coordinates of the Map24 Address on the map.
	 * @param symbolid 		If the logoURL parameter is not specified, it is possible 
	 * 						to specify the ID of a symbol in an image library. All 
	 * 						image libraries are stored in the resource directory. 
	 * 					 	Each image library contains 10 images For example, the 
	 * 						third image in a library called symMap24_2.gif is specified 
	 * 						with 23 (2 is the number of the image library and 3 is the 
	 * 						number of the image).
	 * @param logourl 		The URL of the logo that represents the Map24 Address on the map.
	 * @param description 	An optional description of the Map24 Address that will be shown
	 * 						in the tooltip. In the mapping clients the tooltip is shown when 
	 * 						moving the mouse pointer over the icon or clicking on it.
	 * @param event			An instance of MapObjectEvent that can be used to define mouse events 
	 * 						that trigger MRC commands.
	 * @return 				An instance of XMLCommandWrapper containing the DeclareMap24Location command.
	 */
	public static XMLCommandWrapper DeclareMap24Location(String 	mapobjectid, 
			 Coordinate coordinate,
			 int 		symbolid, 
			 String 	logourl, 
			 String 	description,
			 MapObjectEvent event)
{
				
		
		MapObjectEvent[] Events = { event };
		
DeclareMap24Location location= new DeclareMap24Location();
location.setMapObjectID (mapobjectid);
location.setSymbolID 	(symbolid);
location.setLogoURL    	(logourl);	
location.setCoordinate  (coordinate);
location.setDescription	(description);
location.setEvents(Events);


XMLCommandWrapper cmd = new XMLCommandWrapper();
cmd.setDeclareMap24Location(location);

return cmd;

} // DeclareMap24Location 2nd version
	

	// ------------------------------------------------------------------------
	//  D e c l a r e C u s t o m i z e d M a p 2 4 L o c a t i o n
	// ------------------------------------------------------------------------
	/** 
	 * Helper method for creating a customized Map24 Address.
	 *
	 * You can use the handler and properties parameters to create a customized Map24 Address
	 * as described in the Map24 MRC Digitizers User's Guide. 
	 * 
	 * @param mapobjectid 	The unique identifier for the Map24 Address.
	 * 						This must be a non-empty string value.
	 * @param coordinate 	The coordinates of the Map24 Address on the map.
	 * @param symbolid 		If the logoURL parameter is not specified, it is possible 
	 * 						to specify the ID of a symbol in an image library. All 
	 * 						image libraries are stored in the resource directory. 
	 * 					 	Each image library contains 10 images For example, the 
	 * 						third image in a library called symMap24_2.gif is specified 
	 * 						with 23 (2 is the number of the image library and 3 is the 
	 * 						number of the image).
	 * @param logourl 		The URL of the logo that represents the Map24 Address on the map.
	 * @param description 	An optional description of the Map24 Address that will be shown
	 * 						in the tooltip. In the mapping clients the tooltip is shown when 
	 * 						moving the mouse pointer over the icon or clicking on it.
	 * @param handler 		A reference to a handler class that is implemented on client side. 
	 * 						The handler class takes over control for displaying and event handling 
	 * 						of the map object.
	 * @param properties	Key-value pairs that contain additional information for defining the behavior of the map object.
	 * @return 				An instance of XMLCommandWrapper containing the DeclareMap24Location command.
	 */
	public static XMLCommandWrapper DeclareCustomizedMap24Location(String mapobjectid, Coordinate coordinate, int symbolid, String 	logourl, String description, String handler, Hashtable properties)
	{
		DeclareMap24Location location= new DeclareMap24Location();
		location.setMapObjectID (mapobjectid);
		location.setSymbolID 	(symbolid);
		location.setLogoURL    	(logourl);	
		location.setCoordinate  (coordinate);
		location.setDescription	(description);
		
		location.setCustomize(MapObjectCustomSettings(handler, properties));
		
		XMLCommandWrapper cmd = new XMLCommandWrapper();
		cmd.setDeclareMap24Location(location);
		
		return cmd;
		
	} // DeclareCustomizedMap24Location
	

//	 ------------------------------------------------------------------------
	//  D e c l a r e C u s t o m i z e d M a p 2 4 L o c a t i o n
	// ------------------------------------------------------------------------
	/** 
	 * Helper method for creating a Map24 Click Digitizer.
	 *
	 * You can use the handler and click_property parameters to create a Map24 Click Digitizer
	 * as described in the Map24 MRC Digitizers User's Guide. A  Map24 Click Digitizer
	 * creates a Map24 Address at the position on the map that the user has clicked and
	 * calls the URL specified in the location. 
	 * 
	 * @param mapobjectid 		The unique identifier for the Map24 Address.
	 * 							This must be a non-empty string value.
	 * @param URL				A valid URL. If specified, the mapping clients will display the Map24 
	 * 							Address in a button style (3D frame). When clicking on the button,
	 * 							the specified URL will be shown in a new frame (TargetFrame). 
	 * @param targetframe		If a URL is given, it will be shown in the specified target frame.
	 * @param handler 			The value of the handler for a Map24 Click Digitizer must be "MAP24_CLICK".
	 * @param click_property	Key-value pair for defining the click event that leads to the creation of a Map24 Address.
	 * 							Possible values: left_click (default), right_click, left_doubleclick, or right_doubleclick.
	 * @return 					An instance of XMLCommandWrapper containing the DeclareMap24Location command.
	 */
	public static XMLCommandWrapper DeclareCustomizedMap24Location(String mapobjectid, String URL, String targetframe, String handler, String click_property) 
	{
		DeclareMap24Location location= new DeclareMap24Location();
		location.setMapObjectID (mapobjectid);
		location.setURL(URL);
		location.setTargetFrame(targetframe);
		
		Hashtable<String, String> properties = new Hashtable<String, String>();
		properties.put("CLICK","left_click");
		            
		
		location.setCustomize(MapObjectCustomSettings(handler, properties));
		
		XMLCommandWrapper cmd = new XMLCommandWrapper();
		cmd.setDeclareMap24Location(location);
		
		return cmd;
		
	} // DeclareCustomizedMap24Location
	
	

	// ------------------------------------------------------------------------
	//  D e c l a r e C u s t o m i z e d M a p 2 4 O v a l
	// ------------------------------------------------------------------------
	/**
	 * Helper method for creating a Map24 Oval Digitizer.
	 * 
	 * You can use the handler and properties parameters to create a Map24 Oval Digitizer
	 * as described in the Map24 MRC Digitizers User's Guide. A Map24 Oval Digitizer 
	 * allows to draw an oval on the map. The user can adjust the size and position of 
	 * the oval by dragging handles on the map.
	 * 
	 * @param mapobjectid 	The unique identifier for the Map24 Oval. 
	 * 						This must be a non-empty string value.
	 * @param center 		The coordinate of the oval's center.
	 * @param width 		The oval's diameter in direction of the x-axis.
	 * @param height 		The oval's diameter in direction of the y-axis.
	 * @param fillcolor 	The oval's fill color.
	 * @param bordercolor 	The border color of the oval.
	 * @param handler 		The value of the handler for a Map24 Oval Digitizer must be "MAP24_OVAL_DIGITIZER".
	 * @param properties	Not used.
	 * @return cmd			An instance of XMLCommandWrapper containing the DeclareMap24Oval command.
	 */
	public static XMLCommandWrapper DeclareCustomizedMap24Oval(String mapobjectid, Coordinate center, int width, int height, Color fillcolor, Color bordercolor, String handler, Hashtable properties)
	{
		DeclareMap24Oval oval= new DeclareMap24Oval();
		
		oval.setMapObjectID 		(mapobjectid);
		oval.setCenter  			(center );
		oval.setWidth  				(width);
		oval.setHeight  			(height);		
		oval.setFillColor			(fillcolor);
		oval.setBorderColor			(bordercolor);
		
				
		oval.setCustomize(MapObjectCustomSettings(handler, properties));
		
		
		XMLCommandWrapper cmd= new XMLCommandWrapper();
		cmd.setDeclareMap24Oval(oval);
		
		return cmd;
	
	} // DeclareCustomizedMap24Oval

	
	
	
	// ------------------------------------------------------------------------
	//  D e c l a r e C a n v a s L o c a t i o n
	// ------------------------------------------------------------------------
	/**
	 * Helper method for creating a Canvas Address.
	 * 
	 * Canvas Locations are displayed in mapping clients with icons at their position on the canvas. 
	 * The behavior of a Canvas Address concerning its visual representation is similar to Map24
	 * Locations.
	 * 
	 * @param mapobjectid 	The unique identifier for the Map24 Canvas Address.
	 * 					  	This must be a non-empty string value.
	 * @param anchor      	The Anchor is for specifying the location's position relative to 
	 * 						the canvas borders. It must be either of CENTER, NORTH, NORTHEAST, 
	 * 						EAST, SOUTHEAST, SOUTH, SOUTHWEST, WEST or NORTHWEST.
	 * @param xoffset     	The XOffset and YOffset fields are only taken into account with an 
	 * 						Anchor not equal to CENTER and provide the possibility to shift the 
	 * 						label pixelwise along its calculated position. For example, if the 
	 * 						Anchor is SOUTH and YOffset is 10, the upper border of the label is 
	 * 						10 pixels below the location's position.
	 * @param yoffset     	See xoffset.
	 * @param symbolId    	If the logoURL parameter is not specified, it is possible to specify 
	 * 						the ID of a symbol in an image library. All image libraries are stored 
	 * 						in the resource directory. Each image library contains 10 images For example,
	 * 						the third image in a library called symMap24_2.gif is specified with 23 
	 * 						(2 is the number of the image library and 3 is the number of the image).
	 * @param logoURL     	The URL of the logo that represents the Map24 Address on the map.
	 * @param description 	An optional description of the Map24 Canvas Address that will be shown in the tooltip.
	 * @param url         	A valid URL. If specified, the mapping clients will display the canvas 
	 * 						location in a button style (3D frame). When clicking on the button, 
	 * 						the specified URL will be shown in a new frame (TargetFrame). 
	 * @param targetFrame 	If a URL is given, it will be shown in the specified target frame.
	 * @return				An instance of XMLCommandWrapper containing the DeclareMap24CanvasLocation command.
	 */
	public static XMLCommandWrapper DeclareCanvasLocation(String  mapobjectid, 
			                                              String  anchor,
														  int     xoffset,
														  int     yoffset,
														  int     symbolId,
														  String  logoURL,
														  String  description,
														  String  url,
														  String  targetFrame)
	{
		DeclareCanvasLocation declareloc=	new DeclareCanvasLocation();
		declareloc.setMapObjectID(mapobjectid);
		declareloc.setAnchor(Anchor.fromValue(anchor));
		declareloc.setXOffset(xoffset);
		declareloc.setYOffset(yoffset);
		declareloc.setSymbolID(symbolId);
		declareloc.setLogoURL(logoURL);
		declareloc.setDescription(description);
		declareloc.setTargetFrame(targetFrame);
		declareloc.setURL(url);
		
		XMLCommandWrapper cmd = new XMLCommandWrapper();
		cmd.setDeclareCanvasLocation(declareloc);
		return cmd;
	}
	
	/**
	 * Helper method for removing map objects from a client session.
	 * 
	 * @param mapobjectids 	Array containing the map object IDs to remove. 
	 * 						It is also possible to include the IDs of map object groups.
	 * @return				An instance of XMLCommandWrapper containing the RemoveMapObject command.
	 */
	public static XMLCommandWrapper RemoveMapObject(String[] mapobjectids)
	{
		RemoveMapObject remove=	new RemoveMapObject();
		remove.setMapObjectIDs(mapobjectids);

		XMLCommandWrapper cmd = new XMLCommandWrapper();
		cmd.setRemoveMapObject(remove);
		
		return cmd;
	}
	
	
	/** 
	 * Helper method for creating a Map24 Oval.
	 * 
	 * @param mapobjectid 	The unique identifier for the Map24 Oval. 
	 * 						This must be a non-empty string value.
	 * @param center 		The coordinate of the oval's center.
	 * @param width 		The oval's diameter in direction of the x-axis.
	 * @param height 		The oval's diameter in direction of the y-axis.
	 * @param fillcolor 	The oval's fill color.
	 * @param bordercolor 	The border color of the oval.
	 * @return				An instance of XMLCommandWrapper containing the DeclareMap24Oval command.
	 */
	public static XMLCommandWrapper DeclareMap24Oval(String mapobjectid, Coordinate center, int width, int height, Color fillcolor, Color bordercolor)
	{
		DeclareMap24Oval oval= new DeclareMap24Oval();
		
		oval.setMapObjectID 		(mapobjectid);
		oval.setCenter  			(center );
		oval.setWidth  				(width);
		oval.setHeight  			(height);		
		oval.setFillColor			(fillcolor);
		oval.setBorderColor			(bordercolor);
		
		XMLCommandWrapper cmd= new XMLCommandWrapper();
		cmd.setDeclareMap24Oval(oval);
		
		return cmd;
	
	} // DeclareMap24Oval
	
	
	/** 
	 * Helper method for creating a Map24 Route Object.
	 * 
	 * @param mapobjectid 	The unique identifier for the Map24 Route Object. 
	 * 						This must be a non-empty string value.
	 * @param routeid 		Unique identifier of the calculated route. This ID is returned 
	 * 						when calculating a route with the Map24 Routing Service.
	 * 						For more information see the Map24 Routing Service User's Guide.
	 * @param fillcolor 	The color and tranparency of the Map24 Route Object. You can set 
	 * 						the transparency of the Map24 Route Object in the alpha value. 
	 * 						If a client is able to display the route transparently, the route 
	 * 						will be drawn transparently on top of the street layers. If not, 
	 * 						or the alpha value is set to 255 (no transparency), the route will 
	 * 						be drawn below the streets. When following a street's shape the 
	 * 						street will appear wrapped into the polyline that represents the route. 
	 * 						Note that the MGI Service supports alpha blending.
	 * @return				An instance of XMLCommandWrapper containing the DeclareMap24RouteObject command.
	 */
	public static XMLCommandWrapper DeclareMap24Route(String mapobjectid, String routeid, Color fillcolor)
	{
		DeclareMap24RouteObject route= new DeclareMap24RouteObject();
		
		route.setMapObjectID 	(mapobjectid);
		route.setMap24RouteID	(routeid);
		route.setColor			(fillcolor);
		
		
		XMLCommandWrapper cmd= new XMLCommandWrapper();
		cmd.setDeclareMap24RouteObject(route);
		
		
		return cmd;
	
	} // DeclareMap24Route
	
	
	
	
	/** 
	 * Helper method for creating a Map24 TrafficInfo Object.
	 * 
	 * If you have a license for retrieving traffic information, you can get traffic 
	 * information from the Map24 TrafficInfo Service. You can then push traffic signs 
	 * onto the map. For this you first have to declare TrafficInfo Objects with the 
	 * DeclareMap24TrafficInfo command.
	 * 
	 * @param mapobjectid 	The unique identifier for the Map24 TrafficInfo Object. 
	 * 						This must be a non-empty string value.
	 * @param tinfoid 		The unique identifier of the traffic information in the 
	 * 						Map24 TrafficInfo Service.
	 * @param fillcolor 	The color of the Map24 TrafficInfo Object.
	 * @return				An instance of XMLCommandWrapper containing the DeclareMap24TrafficInfoObject command.
	 */
	public static XMLCommandWrapper DeclareMap24TrafficInfo(String mapobjectid, String tinfoid, Color fillcolor)
	{
		DeclareMap24TrafficInfoObject tinfo= new DeclareMap24TrafficInfoObject();
		
		tinfo.setMapObjectID 		(mapobjectid);
		tinfo.setMap24TrafficInfoID	(tinfoid);
		tinfo.setColor				(fillcolor);
		
		XMLCommandWrapper cmd= new XMLCommandWrapper();
		cmd.setDeclareMap24TrafficInfoObject(tinfo);
		
		return cmd;
	
	} // DeclareMap24TrafficInfo
	
	/**
	 * Helper method for creating a Map24 HTML Object.
	 *  
	 * Map24 HTML Objects display HTML formatted text, images, tables, and forms in a 
	 * separate frame that is pushed onto the map. Map24 HTML Objects can be associated 
	 * either to a map coordinate or to a point on the canvas.
	 * 
	 * The maximum meters per pixel value up to which the HTML object is visible on the map
	 * is set to 100,000 by default.
	 *  
	 * @param mapobjectid 	 	The unique identifier for the Map24 HTML Object. 
	 * 							This must be a non-empty string value.
	 * @param coordinate     	The HTML obect's coordinate on the map.
	 * @param orientation    	The position of the HTML object relative to its associated map coordinate.
	 * 							For further information about the MapObjectOrientation type see the Map24 
	 * 							MapletRemoteControl User's Guide.
	 * @param HTML		    	Defines the content and style of the HTML object. The HTML content is wrapped 
	 * 							in the HTML tag. The HTML content may contain the most often used HTML tags 
	 * 							and attributes. For further information see the Map24 MRC HTML Objects User's Guide.
	 * @return					An instance of XMLCommandWrapper containing the DeclareMap24HTMLObject command.
	 */
	public static XMLCommandWrapper DeclareMap24HTMLObject(String mapobjectid, Coordinate coordinate, MapObjectOrientation orientation, String HTML)
	{
		DeclareMap24HTMLObject HTMLObject= new DeclareMap24HTMLObject();
		
		HTMLObject.setMapObjectID 		(mapobjectid);
		HTMLObject.setCoordinate  		(coordinate );
		HTMLObject.setOrientation  		(orientation);
		HTMLObject.setHTML 				(HTML);		
		HTMLObject.setMaxMPP			(100000);
		
		XMLCommandWrapper cmd= new XMLCommandWrapper();
		cmd.setDeclareMap24HTMLObject(HTMLObject);
		
		
		
		return cmd;
	
	} // DeclareMap24HTMLObject
	
	
	
	
	
	
	

	/**
	 * Helper method for creating a Map24 Polygon.
	 *  
	 * @param mapobjectid   	The unique identifier for the Map24 Polygon. 
	 * 							This must be a non-empty string value.
	 * @param longitudes     	An array containing longitudes of the polygon's coordinates of type float.
	 * @param latitudes      	An array containing latitudes of the polygon's coordinates of type float.
	 * @param fillcolor      	The fill color of the polygon.
	 * @return					An instance of XMLCommandWrapper containing the DeclareMap24Polygon command.
	 */
	public static XMLCommandWrapper DeclareMap24Polygon(String mapobjectid, float[] longitudes, float[] latitudes, Color fillcolor)
	{
		
		CoordinatesArray	coordinates=	new CoordinatesArray();
		
		StringBuffer longsb=	new StringBuffer();
		StringBuffer latsb=		new StringBuffer();
		
		int N = Math.min(longitudes.length, latitudes.length);
		for (int i = 0; i < N; ++i)
		{
			if (i > 0) 
			{
				longsb.append("|");
				latsb.append("|");
			}
			longsb.append(longitudes[i]);
			latsb.append(latitudes[i]);
		}
		
		coordinates.setLongitudes(longsb.toString());
		coordinates.setLatitudes(latsb.toString());
		
		return DeclareMap24Polygon(mapobjectid, coordinates, fillcolor);
		
	
	} // DeclareMap24Polygon
	
	
	/**
	 * Helper method for creating a Map24 Polygon.
	 *  
	 * @param mapobjectid   	The unique identifier for the Map24 Polygon. 
	 * 							This must be a non-empty string value.
	 * @param longitudes     	An array containing longitudes of the polygon's coordinates of type float.
	 * @param latitudes      	An array containing latitudes of the polygon's coordinates of type float.
	 * @param elevations     	An array containing elevations of the polygon's coordinates of type float.
	 * @param fillcolor      	The fill color of the polygon.
	 * @return								An instance of XMLCommandWrapper containing the DeclareMap24Polygon command.
	 */
	public static XMLCommandWrapper DeclareMap24Polygon(String mapobjectid, float[] longitudes, float[] latitudes, float[] elevations, Color fillcolor)
	{
		
		CoordinatesArray	coordinates=	new CoordinatesArray();
		
		StringBuffer longsb=	new StringBuffer();
		StringBuffer latsb=		new StringBuffer();
		StringBuffer elevb=		new StringBuffer();
		
		int N = Math.min(Math.min(longitudes.length, latitudes.length), elevations.length);
		for (int i = 0; i < N; ++i)
		{
			if (i > 0) 
			{
				longsb.append("|");
				latsb.append("|");
				elevb.append("|");
			}
			longsb.append(longitudes[i]);
			latsb.append(latitudes[i]);
			elevb.append(elevations[i]);
		}
		
		coordinates.setLongitudes(longsb.toString());
		coordinates.setLatitudes(latsb.toString());
		coordinates.setElevations(elevb.toString());
		
		return DeclareMap24Polygon(mapobjectid, coordinates, fillcolor);
		
	
	} // DeclareMap24Polygon
	
	
	/**
	 * Helper method for creating a Map24 Polygon Digitizer.
	 *  
	 * @param mapobjectid    The Map24 Polygon's MapObjectID.
	 * @param longitudes     An array containing the longitudes of the polygon.
	 * @param latitudes      An array containing the latitudes of the polygon.
	 * @param fillcolor      The fill color.
	 * @param handler        The customized handler to use.
	 * @param properties     The customized properties.
	 * @return							 An instance of XMLCommandWrapper containing the DeclareMap24Polygon command.
	 */
	public static XMLCommandWrapper DeclareCustomizedMap24Polygon(String mapobjectid, float[] longitudes, float[] latitudes, Color fillcolor, String handler, Hashtable properties)
	{
		
		CoordinatesArray	coordinates=	new CoordinatesArray();
		
		StringBuffer longsb=	new StringBuffer();
		StringBuffer latsb=		new StringBuffer();
		
		int N = Math.min(longitudes.length, latitudes.length);
		for (int i = 0; i < N; ++i)
		{
			if (i > 0) 
			{
				longsb.append("|");
				latsb.append("|");
			}
			longsb.append(longitudes[i]);
			latsb.append(latitudes[i]);
		}
		
		coordinates.setLongitudes(longsb.toString());
		coordinates.setLatitudes(latsb.toString());
		
		return DeclareCustomizedMap24Polygon(mapobjectid, coordinates, fillcolor, handler, properties);
		
	
	} // DeclareMap24Polygon
	
	
	
	
	/**
	* Helper method for creating a Map24 Polygon.
	*
	* @param mapobjectid    The Map24 Polygon's MapObjectID.
	* @param coordinates		The polygon's coordinates in an instance of CoordinatesArray.
	* @param fillcolor			The fill color of the polygon.
	* @return								An instance of XMLCommandWrapper containing the DeclareMap24Polygon command.
	*/
	public static XMLCommandWrapper DeclareMap24Polygon(String mapobjectid, CoordinatesArray coordinates, Color fillcolor)
	{
		DeclareMap24Polygon polygon=		new DeclareMap24Polygon();
		
		
		polygon.setMapObjectID(mapobjectid);
		polygon.setCoordinates(coordinates);
		polygon.setFillColor(fillcolor);
		
		XMLCommandWrapper cmd= new XMLCommandWrapper();
		cmd.setDeclareMap24Polygon(polygon);
		
		return cmd;
	} // DeclareMap24Polygon
	
	
	
	
	/**
	 * Helper method for creating a Map24 Polygon Digitizer.
	 *  
	 * @param mapobjectid    The Map24 Polygon Digitizer's MapObjectID.
	 * @param coordinates    The polygon digitizer's coordinates in an instance of CoordinatesArray.
	 * @param fillcolor      The fill color of the polygon.
	 * @param handler        The customized handler to use.
	 * @param properties     The customized properties.
	 * @return							 An instance of XMLCommandWrapper containing the DeclareMap24Polygon command.
	 */
	public static XMLCommandWrapper DeclareCustomizedMap24Polygon(String mapobjectid, CoordinatesArray coordinates, Color fillcolor, String handler, Hashtable properties)
	{
		DeclareMap24Polygon polygon=		new DeclareMap24Polygon();
		
		polygon.setMapObjectID(mapobjectid);
		polygon.setCoordinates(coordinates);
		polygon.setFillColor(fillcolor);
		
		polygon.setCustomize(MapObjectCustomSettings(handler, properties));
		XMLCommandWrapper cmd= new XMLCommandWrapper();
		cmd.setDeclareMap24Polygon(polygon);
		
		return cmd;
	} // DeclareMap24Polygon
	
	
	
	/**
	 * Helper method for creating a Map24 Polygon Digitizer.
	 *  
	 * @param mapobjectid    The Map24 Polygon Digitizer's MapObjectID.
	 * @param coordinates    The polygon digitizer's coordinates in an instance of CoordinatesArray.
	 * @param fillcolor      The fill color of the polygon.
	 * @param description	 	 The tooltip description.
	 * @param handler        The customized handler to use.
	 * @param properties     The customized properties.
	 * @return							 An instance of XMLCommandWrapper containing the DeclareMap24Polygon command.
	 */
	public static XMLCommandWrapper DeclareCustomizedMap24Polygon(String mapobjectid, CoordinatesArray coordinates, Color fillcolor, String description, String handler, Hashtable properties)
	{
		DeclareMap24Polygon polygon=		new DeclareMap24Polygon();
		
		polygon.setMapObjectID(mapobjectid);
		polygon.setCoordinates(coordinates);
		polygon.setFillColor(fillcolor);
		polygon.setDescription(description);
		
		polygon.setCustomize(MapObjectCustomSettings(handler, properties));
		XMLCommandWrapper cmd= new XMLCommandWrapper();
		cmd.setDeclareMap24Polygon(polygon);
		
		return cmd;
	} // DeclareMap24Polygon

	/**
	 * Helper method for creating a Map24 Polyline.
	 *  
	 * @param mapobjectid    The Map24 Polyline's MapObjectID.
	 * @param coordinates    The polyline digitizer's coordinates in an instance of CoordinatesArray.
	 * @param fillcolor      The fill color of the polyline.
	 * @param description	 	 The tooltip description.
	 * @param handler        The customized handler to use.
	 * @param properties     The customized properties.
	 * @return							 An instance of XMLCommandWrapper containing the DeclareMap24Polyline command.
	 */
	public static XMLCommandWrapper DeclareMap24Polyline(String mapobjectid, float[] longitudes, float[] latitudes, String description, Color fillcolor, Color arrowcolor)
	{
		
		CoordinatesArray	coordinates=	new CoordinatesArray();
		
		StringBuffer longsb=	new StringBuffer();
		StringBuffer latsb=		new StringBuffer();
		
		int N = Math.min(longitudes.length, latitudes.length);
		for (int i = 0; i < N; ++i)
		{
			if (i > 0) 
			{
				longsb.append("|");
				latsb.append("|");
			}
			longsb.append(longitudes[i]);
			latsb.append(latitudes[i]);
		}
		
		coordinates.setLongitudes(longsb.toString());
		coordinates.setLatitudes(latsb.toString());
		
		return DeclareMap24Polyline(mapobjectid, coordinates, description, fillcolor, arrowcolor);
		
	
	} // DeclareMap24Polygon

	/**
	 * Helper method for creating a Map24 Polyline.
	 *  
	 * @param mapobjectid    The Map24 Polyline's MapObjectID.
	 * @param coordinates    The polyline's coordinates in an instance of CoordinatesArray.
	 * @param fillcolor      The fill color of the polyline.
	 * @param width			 		 The width of the polyline in pixels.
	 * @return							 An instance of XMLCommandWrapper containing the DeclareMap24Polyline command.
	 */
	public static XMLCommandWrapper DeclareMap24Polyline(String mapobjectid, CoordinatesArray coordinates, Color color, int width)
	{
		
			
		PaintRuleSTROKEDetails details = new PaintRuleSTROKEDetails();
		
		details.setColor(color);
		details.setMinMPP(0);
		details.setWidth(width);
		
		PaintRuleSTROKE PaintRule = new PaintRuleSTROKE();
		PaintRule.setMaxMPP(10000);
		PaintRule.setDetails(new PaintRuleSTROKEDetails[]{details});
		PaintRule.setDrawPhase(PaintRuleDrawPhase.ROADS);
				
		DeclareMap24Polyline polyline=		new DeclareMap24Polyline();
		
		polyline.setMapObjectID(mapobjectid);
		polyline.setCoordinates(coordinates);
		polyline.setStrokePaintRules(new PaintRuleSTROKE[]{PaintRule});
		
		XMLCommandWrapper cmd= new XMLCommandWrapper();
				
		cmd.setDeclareMap24Polyline(polyline);
		
		return cmd;
	} // DeclareMap24Polyline

	/**
	* Helper method for creating a Map24 Polyline.
	*
	* @param mapobjectid    The Map24 Polyline's MapObjectID.
	* @param longitudes			An array containing the longitudes of the polyline.
	* @param latitudes			An array containing the latitudes of the polyline.
	* @param fillcolor			The fill color of the polyline.
	* @param width					The width of the polyline in pixels.
	* @return							  An instance of XMLCommandWrapper containing the DeclareMap24Polyline command.
	*/
	public static XMLCommandWrapper DeclareMap24Polyline(String mapobjectid, float[] longitudes, float[] latitudes, Color fillcolor, int width)
	{
		
		CoordinatesArray	coordinates=	new CoordinatesArray();
		
		StringBuffer longsb=	new StringBuffer();
		StringBuffer latsb=		new StringBuffer();
		
		int N = Math.min(longitudes.length, latitudes.length);
		for (int i = 0; i < N; ++i)
		{
			if (i > 0) 
			{
				longsb.append("|");
				latsb.append("|");
			}
			longsb.append(longitudes[i]);
			latsb.append(latitudes[i]);
		}
		
		coordinates.setLongitudes(longsb.toString());
		coordinates.setLatitudes(latsb.toString());
		
		return DeclareMap24Polyline(mapobjectid, coordinates, fillcolor, width);
		
	
	} // DeclareMap24Polygon

  /**
  * Helper method for creating a Map24 Polyline.
  *
  * @param mapobjectid    The Map24 Polyline's MapObjectID.
  * @param longitudes			An array containing the longitudes of the polyline.
	* @param latitudes			An array containing the latitudes of the polyline.
	* @param fillcolor			The fill color of the polyline.
	* @return								An instance of XMLCommandWrapper containing the DeclareMap24Polyline command.
  */
	public static XMLCommandWrapper DeclareMap24Polyline(String mapobjectid, float[] longitudes, float[] latitudes, Color fillcolor)
	{
		
		CoordinatesArray	coordinates=	new CoordinatesArray();
		
		StringBuffer longsb=	new StringBuffer();
		StringBuffer latsb=		new StringBuffer();
		
		int N = Math.min(longitudes.length, latitudes.length);
		for (int i = 0; i < N; ++i)
		{
			if (i > 0) 
			{
				longsb.append("|");
				latsb.append("|");
			}
			longsb.append(longitudes[i]);
			latsb.append(latitudes[i]);
		}
		
		coordinates.setLongitudes(longsb.toString());
		coordinates.setLatitudes(latsb.toString());
		
		return DeclareMap24Polyline(mapobjectid, coordinates, fillcolor);
		
	
	} // DeclareMap24Polygon
	

	/**
	 * Helper method for creating a Map24 Polyline Digitizer.
	 *
	 * @param mapobjectid  The Map24 Polyline digitizer's MapObjectID.
	 * @param longitudes	 An array containing the longitudes of the polyline.
	 * @param latitudes		 An array containing the latitudes of the polyline.
	 * @param fillcolor		 The fill color of the polyline.
	 * @param handler			 The customized handler to use.
	 * @param properties   The customized properties.
	 * @return						 An instance of XMLCommandWrapper containing the DeclareMap24Polyline command.
	 */
	public static XMLCommandWrapper DeclareCustomizedMap24Polyline(String mapobjectid, float[] longitudes, float[] latitudes, Color fillcolor, String handler, Hashtable properties)
	{
		
		CoordinatesArray	coordinates=	new CoordinatesArray();
		
		StringBuffer longsb=	new StringBuffer();
		StringBuffer latsb=		new StringBuffer();
		
		int N = Math.min(longitudes.length, latitudes.length);
		for (int i = 0; i < N; ++i)
		{
			if (i > 0) 
			{
				longsb.append("|");
				latsb.append("|");
			}
			longsb.append(longitudes[i]);
			latsb.append(latitudes[i]);
		}
		
		coordinates.setLongitudes(longsb.toString());
		coordinates.setLatitudes(latsb.toString());
		
		return DeclareCustomizedMap24Polyline(mapobjectid, coordinates, fillcolor, handler, properties);
	
	} // DeclareMap24Polygon
	

	/**
	 * Helper method for creating a Map24 Polyline.
	 *
	 * @param mapobjectid  The Map24 Polyline's MapObjectID.
	 * @param coordinates	 The coordinates of the Map24 Polyline of type CoordinatesArray.
	 * @param fillcolor		 The fill color of the polyline.
	 * @return 						 An instance of XMLCommandWrapper containing the DeclareMap24Polyline command.
	 */
	public static XMLCommandWrapper DeclareMap24Polyline(String mapobjectid, CoordinatesArray coordinates, Color fillcolor)
	{
		DeclareMap24Polyline polygon=		new DeclareMap24Polyline();
		
		polygon.setMapObjectID(mapobjectid);
		polygon.setCoordinates(coordinates);
		polygon.setColor(fillcolor);
			
		
		XMLCommandWrapper cmd= new XMLCommandWrapper();
		cmd.setDeclareMap24Polyline(polygon);
		
		return cmd;
	} // DeclareMap24Polyline
	
	/**
	* Helper method for creating a Map24 Polyline with arrows.
	*
	* @param mapobjectid	 The Map24 Polyline's MapObjectID.
	* @param coordinates	 The coordinates of the Map24 Polyline of type CoordinatesArray.
	* @param description	 The tooltip description for the Map24 Polyline.
	* @param fillcolor		 The fill color of the polyline.
	* @param arrowcolor	   The arrow color of the polyline.
	* @return 						 An instance of XMLCommandWrapper containing the DeclareMap24Polyline command.
	*/
	public static XMLCommandWrapper DeclareMap24Polyline(String mapobjectid, CoordinatesArray coordinates, String description, Color fillcolor, Color arrowcolor)
	{
		DeclareMap24Polyline polyline=		new DeclareMap24Polyline();
		
		polyline.setMapObjectID(mapobjectid);
		polyline.setCoordinates(coordinates);
		polyline.setColor(fillcolor);
		polyline.setArrowColor(arrowcolor);
		polyline.setDescription(description);
			
		
		XMLCommandWrapper cmd= new XMLCommandWrapper();
		cmd.setDeclareMap24Polyline(polyline);
		
		return cmd;
	} // DeclareMap24Polyline
	
	/**
	* Helper method for creating a Map24 Polyline.
	*
	* @param mapobjectid	 The Map24 Polyline's MapObjectID.
	* @param coordinates	 The coordinates of the Map24 Polyline of type CoordinatesArray.
	* @param description	 The tooltip description for the Map24 Polyline.
	* @param fillcolor		 The fill color of the polyline.
	* @return 						 An instance of XMLCommandWrapper containing the DeclareMap24Polyline command.
	*/
	public static XMLCommandWrapper DeclareMap24Polyline(String mapobjectid, CoordinatesArray coordinates, String description, Color fillcolor)
	{
		DeclareMap24Polyline polyline=		new DeclareMap24Polyline();
		
		polyline.setMapObjectID(mapobjectid);
		polyline.setCoordinates(coordinates);
		polyline.setColor(fillcolor);
		polyline.setDescription(description);
			
		
		XMLCommandWrapper cmd= new XMLCommandWrapper();
		cmd.setDeclareMap24Polyline(polyline);
		
		return cmd;
	} // DeclareMap24Polyline

	
	
	
/**
	* Helper method for creating a Map24 Polyline Digitizer.
	*
	* @param mapobjectid	 The Map24 Polyline Digitizer's MapObjectID.
	* @param coordinates	 The coordinates of the Map24 Polyline of type CoordinatesArray.
	* @param fillcolor		 The fill color of the polyline.
	* @param handler			 The customized handler.
	* @param properties		 Additional properties of the Map24 Polyline Digitizer.
	* @return 						 An instance of XMLCommandWrapper containing the DeclareMap24Polyline command.
	*/
	public static XMLCommandWrapper DeclareCustomizedMap24Polyline(String mapobjectid, CoordinatesArray coordinates, Color fillcolor, String handler, Hashtable properties)
	{
		DeclareMap24Polyline polygon=	new DeclareMap24Polyline();
		
		polygon.setMapObjectID(mapobjectid);
		polygon.setCoordinates(coordinates);
		polygon.setColor(fillcolor);
	
		polygon.setCustomize(MapObjectCustomSettings(handler, properties));
		
		XMLCommandWrapper cmd= new XMLCommandWrapper();
		cmd.setDeclareMap24Polyline(polygon);
		
		return cmd;
	} // DeclareCustomizedMap24Polyline
	
	
	
	
	// ------------------------------------------------------------------------
	//  M A P L E T - R E M O T E - C O N T R O L 
	// ------------------------------------------------------------------------
	
	private static class MapletRemoteControlThread extends Thread
	{
		Map24MapletRemoteControlPortType 	mrcontrolPort;
		RequestHeader 						requestHeader;
		MapletRemoteControlRequest 			mapletRemoteControlRequest;
		MapletRemoteControlResponse 		mapletRemoteControlResponse;
		
		MapletRemoteControlThread(Map24MapletRemoteControlPortType _mrcontrolPort, RequestHeader _requestHeader, MapletRemoteControlRequest _mapletRemoteControlRequest)
		{
			this.mrcontrolPort=					_mrcontrolPort;
			this.requestHeader=					_requestHeader;
			this.mapletRemoteControlRequest=	_mapletRemoteControlRequest;
		
		}
		
		public void run()
		{
			try
			{	mapletRemoteControlResponse= mrcontrolPort.mapletRemoteControl(requestHeader, mapletRemoteControlRequest);
			}
			catch(Exception ee)
			{}
		}
		
		
	} // MapletRemoteControlThread
	
	  /**
	  * Helper method for sending a mapletRemoteControl request to the Map24 MapletRemoteControl Service.
	  *
	  * @param binding  	URL of the Map24 MapletRemoteControl service.
	  * @param map24id	  Map24 ID used for authentication.
	  * @param clientid		ID of the Map24 session.
	  * @param commands 	The MRC commands to be processed.
	  * @return						An instance of MapletRemoteControlResponse. 
	  */
    public static MapletRemoteControlResponse MapletRemoteControl(String binding, String map24id, String clientid, XMLCommandWrapper[] commands)
    {
		MapletRemoteControlResponse response= null;
		
		/////////////////////////////////////////////////////		
		// create mapletRemoteControl
		/////////////////////////////////////////////////////		
		Map24MRC mapletRemoteControl = new Map24MRC();
		mapletRemoteControl.setMap24SessionID(clientid);
		mapletRemoteControl.setCommands(commands);
		
		
		MapletRemoteControlRequest mapletRemoteControlRequest= new MapletRemoteControlRequest();
		mapletRemoteControlRequest.setMap24MRC(mapletRemoteControl);
		
		
		
		/////////////////////////////////////////////////////		
		// create request header
		/////////////////////////////////////////////////////
		RequestHeader requestHeader = new RequestHeader();
		requestHeader.setMap24ID  (map24id);
		requestHeader.setClientID (clientid);
		
							
		try 
		{				
			Map24MapletRemoteControlLocator locator = new Map24MapletRemoteControlLocator();

			/////////////////////////////////////////////////////		
			// create port
			/////////////////////////////////////////////////////					
			Map24MapletRemoteControlPortType mrcontrolPort = null;
			
	
			try
			{	java.net.URL url = new java.net.URL(binding+"&sid="+clientid);
				
				mrcontrolPort = locator.getMap24MapletRemoteControlPort(url);
				
				com.mapsolute.map24webservices15.clients.axis.stubs.Map24MapletRemoteControlBindingStub stub=
					(com.mapsolute.map24webservices15.clients.axis.stubs.Map24MapletRemoteControlBindingStub)mrcontrolPort;
				
				
				
				stub._setProperty(org.apache.axis.client.Call.SEND_TYPE_ATTR,  Boolean.FALSE);
				stub._setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE);
				stub._setProperty(org.apache.axis.AxisEngine.PROP_SEND_XSI,    Boolean.FALSE);
						
			
				
			}
			catch(Exception ex)
			{
				System.err.println(ex);
			}				
						
			////////////////////////////////////////////////////////		
			// invoke remote operation and get the response object
			////////////////////////////////////////////////////////								
			
			////////////////////////////////////////////////////////								
			// for debugging print out the submitted request.
			////////////////////////////////////////////////////////	
			//System.out.println("-------- doing mapletremotecontrol request at " + new java.util.Date() + " -------------");
			//com.netsolut.xmlutils.XMLSerializer.dumpToXML(mapletRemoteControlRequest, System.out);
			//System.out.println("-------------------------------------------------------------------------------------------------");
			
			
			
			MapletRemoteControlThread mrcthread= new MapletRemoteControlThread(mrcontrolPort, requestHeader, mapletRemoteControlRequest);
			
			if (WAIT_FOR_MRC_RESPONSE) 
				mrcthread.run(); 
			else
				mrcthread.start(); 
				
			response = mrcthread.mapletRemoteControlResponse;
			
			/*
			/////////////////////////////////////////////////////		
			// dump resulted data as xml to console
			/////////////////////////////////////////////////////				
			
			System.out.println("-- DUMP RESULT TO XML --");
			com.mapsolute.xmlutils.XMLSerializer.dumpToXML(response, System.out);
			*/
			
			System.out.println();
		}
		catch(Exception e)
		{
			System.err.println(e);
		}
		
		return response;
		
		
    } // MapletRemoteControl
    
	
	
//	/** Helper-method for instantiating a XMLCommandWrapper for a DeclareMap24Oval-Command
//	 * 
//	 * @param mapobjectid The Map24Ovals MapObjectID
//	 * @param center The Coordinate of the Ovals center-point
//	 * @param width The width (x-radius) of the Oval
//	 * @param height The height (y-radius) of the Oval
//	 * @param fillcolor The FillColor of the Oval
//	 * @param bordercolor The BorderColor of the Oval
//	 * @return
//	 */
//	public static DigitizeOvalRequest DigitizeOvalRequest(String mapobjectid, Coordinate center, int width, int height, String url, String targetframe)
//	{
//		DigitizeOvalRequest oval= new DigitizeOvalRequest();
//		
//		oval.setMapObjectID 		(mapobjectid);
//		oval.setCenter  			(center );
//		oval.setWidth  				(width);
//		oval.setHeight  			(height);		
//		oval.setURL					(url);
//		oval.setTargetFrame			(targetframe);
//		
//		return oval;
//	
//	} // DeclareMap24Oval
//	
//	
//	
//	/** 
//	 * Helper-method for instantiating a XMLCommandWrapper for a DigitizePolygon-Command
//	 * 
//	 * @param mapobjectid The Map24Polygons MapObjectID
//	 * @param center The Coordinate of the Ovals center-point
//	 * @param width The width (x-radius) of the Oval
//	 * @param height The height (y-radius) of the Oval
//	 * @param fillcolor The FillColor of the Oval
//	 * @param bordercolor The BorderColor of the Oval
//	 * @return
//	 */
//	public static DigitizePolygonRequest DigitizePolygonRequest(String mapobjectid, float[] longitudes, float[] latitudes, String url, String targetframe)
//	{
//		DigitizePolygonRequest 	polygon= 		new DigitizePolygonRequest();
//		CoordinatesArray		coordinates=	new CoordinatesArray();
//		
//		StringBuffer longsb=	new StringBuffer();
//		StringBuffer latsb=		new StringBuffer();
//		
//		int N = Math.min(longitudes.length, latitudes.length);
//		for (int i = 0; i < N; ++i)
//		{
//			if (i > 0) 
//			{
//				longsb.append("|");
//				latsb.append("|");
//			}
//			longsb.append(longitudes[i]);
//			latsb.append(latitudes[i]);
//		}
//		
//		coordinates.setLongitudes(longsb.toString());
//		coordinates.setLatitudes(latsb.toString());
//		
//		polygon.setMapObjectID  (mapobjectid);
//		polygon.setCoordinates  (coordinates);
//		polygon.setURL		    (url);
//		polygon.setTargetFrame	(targetframe);
//		
//		return polygon;
//	
//	} // DigitizePolygonRequest
//	
//
//	
//	// ------------------------------------------------------------------------
//	//  D i g i t i z e  O v a l
//	// ------------------------------------------------------------------------
//    public static DigitizeOvalResponse DigitizeOval(String binding, String map24ID, String clientid, DigitizeOvalRequest request)
//    {
//    	DigitizeOvalResponse response= null;			
//		
//		/////////////////////////////////////////////////////		
//		// create request header
//		/////////////////////////////////////////////////////
//		RequestHeader requestHeader = new RequestHeader();
//		requestHeader.setMap24ID  (map24ID);
//		requestHeader.setClientID (clientid);
//							
//		try 
//		{				
//			Map24MapletRemoteControlLocator locator = new Map24MapletRemoteControlLocator();
//
//			/////////////////////////////////////////////////////		
//			// create port
//			/////////////////////////////////////////////////////					
//			Map24MapletRemoteControlPortType mrcontrolPort = null;
//				
//			try
//			{	java.net.URL url = new java.net.URL(binding+"&sid="+clientid);
//				
//				mrcontrolPort = locator.getMap24MapletRemoteControlPort(url);
//			}
//			catch(Exception ex)
//			{
//				System.err.println(ex);
//			}				
//						
//			////////////////////////////////////////////////////////		
//			// invoke remote operation and get the response object
//			////////////////////////////////////////////////////////										
//			response = mrcontrolPort.digitizeOval(requestHeader, request);
//		}
//		catch(Exception e)
//		{
//			System.err.println(e);
//		}
//		
//		return response;
//		
//
//    } // DigitizeOval
//   
//    
//    
//    
//    // ------------------------------------------------------------------------
//	  //  D i g i t i z e  P o l y g o n
//	  // ------------------------------------------------------------------------
//    public static DigitizePolygonResponse DigitizePolygon(String binding, String map24ID, String clientid, DigitizePolygonRequest request)
//    {
//    	DigitizePolygonResponse response= null;			
//		
//		/////////////////////////////////////////////////////		
//		// create request header
//		/////////////////////////////////////////////////////
//		RequestHeader requestHeader = new RequestHeader();
//		requestHeader.setMap24ID  (map24ID);
//		requestHeader.setClientID (clientid);
//							
//		try 
//		{				
//			Map24MapletRemoteControlLocator locator = new Map24MapletRemoteControlLocator();
//
//			/////////////////////////////////////////////////////		
//			// create port
//			/////////////////////////////////////////////////////					
//			Map24MapletRemoteControlPortType mrcontrolPort = null;
//				
//			try
//			{	java.net.URL url = new java.net.URL(binding+"&sid="+clientid);
//				
//				mrcontrolPort = locator.getMap24MapletRemoteControlPort(url);
//			}
//			catch(Exception ex)
//			{
//				System.err.println(ex);
//			}				
//						
//			////////////////////////////////////////////////////////		
//			// invoke remote operation and get the response object
//			////////////////////////////////////////////////////////										
//			response = mrcontrolPort.digitizePolygon(requestHeader, request);
//		}
//		catch(Exception e)
//		{
//			System.err.println(e);
//		}
//		
//		return response;
//		
//
//    } // DigitizeOval
   
    
    
    
    
    // ----------------------------------------------------------
    // private helper methods
    // ----------------------------------------------------------
    
	/*
	 * private helper method for instantiating a custom settings object
	 * for the specified handler and properties
	 * @param handler
	 * @param properties
	 * @return
	 */
	private static MapObjectCustomSettings MapObjectCustomSettings(String handler, Hashtable properties)
	{
		MProperty[] props=	null;
		
		if (properties != null)
		{
			props= new MProperty[properties.size()];
			
			int cnt= 0;
			for (Enumeration keys= properties.keys(); (keys.hasMoreElements()); )
			{
				props[cnt]=	new MProperty();
				props[cnt].setKey	((String)keys.nextElement());
				props[cnt].setValue	((String)properties.get(props[cnt].getKey()));	
				
				cnt++;
			}
		}

		MapObjectCustomSettings customize= new MapObjectCustomSettings();
		customize.setHandler(handler);
		customize.setProperties(props);
		return customize;
	}
	
	
	
	//	 ------------------------------------------------------------------------
	//  G e t M a p l e t S e s s i o n
	// ------------------------------------------------------------------------
	
	/**
	* Helper method for sending a GetMapletSession request to the Map24 MRC Service.
	*
	* The GetMapletSession request is used for retrieving information on the current state of a client session.
	* It is possible to filter the MRC commands and MapObjectIDs in this session.
	* 
	* @param binding  				URL of the Map24 MapletRemoteControl service.
	* @param map24id	  			Map24 ID used for authentication.
	* @param clientid					ID of the Map24 session.
	* @param commandsFilter		Optional parameter for specifying the type of MRC command. The Map24 MRC then filters the MRC commands in the Map24 session and returns only the commands with the specified type
	* @param objectIdsFilter	Optional parameter for specifying MapObjectIDs. The Map24 MRC then filters the existing MapObjectIDs in the Map24 session and returns only the specified IDs.
	* @return									An instance of GetMapletSessionResponse containing information on the state of the current client session.
	*/
	public static GetMapletSessionResponse GetMapletSession(String binding, String map24id, String clientid, String[] commandsFilter, String[] objectIdsFilter)
    {
    	GetMapletSessionResponse response= null;
				
    	GetMapletSessionRequest request= new GetMapletSessionRequest();
    	
    	if (commandsFilter != null)
    	  request.setMap24MRCComandsFilter(commandsFilter);
    	
    	if (objectIdsFilter != null)
      	  request.setMap24MRCMapObjectIDsFilter(objectIdsFilter);
    	
		/////////////////////////////////////////////////////		
		// create request header
		/////////////////////////////////////////////////////
		RequestHeader requestHeader = new RequestHeader();
		requestHeader.setMap24ID  (map24id);
		requestHeader.setClientID (clientid);
	
				
		try 
		{				
			Map24MapletRemoteControlLocator locator= new Map24MapletRemoteControlLocator();
			
			
			/////////////////////////////////////////////////////		
			// create port
			/////////////////////////////////////////////////////					
			Map24MapletRemoteControlPortType mrcontrolPort = null;
			
	
			try
			{	java.net.URL url = new java.net.URL(binding+"&sid="+clientid);
						
				mrcontrolPort = locator.getMap24MapletRemoteControlPort(url);
					
							
			}
			catch(Exception ex)
			{
				System.err.println(ex);
			}				
			
			response = mrcontrolPort.getMapletSession(requestHeader, request);

			
		}
		catch(Exception e)
		{
			System.err.println(e);
		}
		
		return response;
		
		
    } // GetMapletSession
	
	
		/**
	* Helper method for sending a GetMapletSession request to the Map24 MRC Service.
	*
	* The GetMapletSession request is used for retrieving information on the current state of a client session.
	* 
	* @param binding  				URL of the Map24 MapletRemoteControl service.
	* @param map24id	  			Map24 ID used for authentication.
	* @param clientid					ID of the Map24 session.
	* @return									An instance of GetMapletSessionResponse containing information on the state of the current client session.
	*/
    public static GetMapletSessionResponse GetMapletSession(String binding, String map24id, String clientid)
    {
    	  	
    	return GetMapletSession(binding, map24id, clientid, null, null);

    } // GetMapletSession
    
    
    /** 
     * Helper method for retrieving information on the state of a client session.
     *
     *  The Map24 mapping clients report their current settings (MapletInfo) to the 
     *  Map24 Web Services on every change of the current map view (panning, zooming etc.).
     *
     *  In case of failures the method returns null.
     *
     * @param binding 			The address of the Map24 Web Service's MapletReomteControl interface.
     * @param map24id 			Map24 ID used for authentication.
	   * @param clientid			ID of the Map24 session.
     * @return 							An instance of GetMapletSessionResponse containing information on the state of the current client session. 
     */
    public static MapletInfoRequest GetMapletInfo(String binding, String map24id, String clientid)
    {
    	GetMapletSessionResponse response= GetMapletSession(binding, map24id, clientid, new String[] { "none" }, new String[] { "none" });
    	
    	return (response == null) ? null : response.getMap24MapletInfo();

    } // MapletInfoRequest
    
    
    /** Helper method for retrieving the center coordinate of a mapping client's current map view.
     *
     * The Map24 mapping clients report their current settings (MapletInfo) to the 
     * Map24 Web Services on every change of the map view (panning, zooming etc.).
     *
     * In case of failures the method returns null.
     *
     * @param binding 			The address of the Map24 Web Service's MapletReomteControl interface.
     * @param map24id 			Map24 ID used for authentication.
	   * @param clientid			ID of the Map24 session.
     * @return 							The coordinate of the current map view's center point. 
     */
    public static Coordinate GetMapletInfoCenterCoordinate(String binding, String map24id, String clientid)
    {
    	try
		{
	    	MapletInfoRequest mapletinfo= GetMapletInfo(binding, map24id, clientid);
	    	
	    	if (mapletinfo != null)
	    	{
	    		Coordinate c= new Coordinate();
	    		
	    		c.setLatitude((mapletinfo.getUpperLeftCoordinate().getLatitude() + mapletinfo.getLowerRightCoordinate().getLatitude()) / 2.0f);
	    		c.setLongitude((mapletinfo.getUpperLeftCoordinate().getLongitude() + mapletinfo.getLowerRightCoordinate().getLongitude()) / 2.0f);
	    		
	    		return c;
	    		
	    	}
		}
    	catch(Exception ee)
		{}
    	
    	return null;

    } // GetMapletInfoCenterCoordinate
    
    
    /** Helper method used to check if a given coordinate is inside a specified polygon.
     *
     * @param longs 	The longitudes of the polygon.
     * @param lats 		The latitudes of the polygon.
     * @param long1 	The longitude of the point.
     * @param lat1 		The latitude of the point.
     * @return 				TRUE if the coordinate is inside the Polygon, FALSE if it is outside.
     */
    public static boolean CoordInsidePolygon(float[] longs, float[] lats, float long1, float lat1)
    {
    	int[] xarr= new int[longs.length];
		int[] yarr= new int[lats.length];
		for (int i= 0; (i < xarr.length); i++)
    	{
    		xarr[i]= (int)(longs[i]*1000);
    		yarr[i]= (int)(lats[i]*1000);
    	}
		
		Polygon Polygon = new Polygon(xarr, yarr, xarr.length);
		
		if (Polygon.contains(long1*1000, lat1*1000))
		{
			return true;
		}
		else
			return false;
    } // CoordInsidePolygon
    
    /** 
     *  Helper method used to convert coordinates from DMS (Degrees Minutes Seconds) format to M.m (decimal minutes).
     *
     * @param longitude The longitude as a string. The format can be either "49° 42' 36\" N" (DMS) or "5342.0828N" (M.m).
     * @param latitude  The latitude as a string. The format can be either "123° 15' 10\" W" (DMS) or "5342.0828W" (M.m).
     * @return Coordinate The coordinate of type Coordinate in the format M.m.
     */
    public static Coordinate ConvertCoord(String longitude, String latitude)
    {
    	try
    	{
    	
    	Coordinate coord = new Coordinate();
    		
    	if (longitude.contains("°") && (longitude.contains("'")||longitude.contains("′"))) //Example: "49° 15′ 9.8″ N";
    	{			
    	int col=0;
		String[] longs = new String[4];
		
		StringTokenizer st1 = new StringTokenizer(longitude," ");
		while (st1.hasMoreTokens())
		{
			//get next token and store it in the array
			longs[col] = st1.nextToken();
			col++;
		}
		col=0;
		
		String[] lats = new String[4];
		
		StringTokenizer st2 = new StringTokenizer(latitude," ");
		while (st2.hasMoreTokens())
		{
			//get next token and store it in the array
			lats[col] = st2.nextToken();
			col++;
		}
	
		float latdegree = Float.valueOf(lats[0].substring(0, lats[0].indexOf("°")));
		
				
		float latminute;
		
		
		if (lats[1].contains("′"))
			latminute = Float.valueOf(lats[1].substring(0, lats[1].indexOf("′")));
		else if (lats[1].contains("'"))
			latminute = Float.valueOf(lats[1].substring(0, lats[1].indexOf("'")));
		else
		{
    		System.out.println("Wrong format!");
    		return null;
    	}
		
		float latsecond;
		
		if (lats[2].contains("″"))
			latsecond = Float.valueOf(lats[2].substring(0, lats[2].indexOf("″")));
		else if (lats[2].contains("\""))
			latsecond = Float.valueOf(lats[2].substring(0, lats[2].indexOf("\"")));
		else
		{
    		System.out.println("Wrong format!");
    		return null;
    	}
		
		float longdegree = Float.valueOf(longs[0].substring(0, longs[0].indexOf("°")));
		
		float longminute;
		
		if (longs[1].contains("′"))
			longminute = Float.valueOf(longs[1].substring(0, longs[1].indexOf("′")));
		else  if (longs[1].contains("'"))
			longminute = Float.valueOf(longs[1].substring(0, longs[1].indexOf("'")));
		else
		{
    		System.out.println("Wrong format!");
    		return null;
    	}
		
		float longsecond;
		
		if (longs[2].contains("″"))
			longsecond = Float.valueOf(longs[2].substring(0, longs[2].indexOf("″")));
		else if (longs[2].contains("\""))
			longsecond = Float.valueOf(longs[2].substring(0, longs[2].indexOf("\"")));
		else
		{
    		System.out.println("Wrong format!");
    		return null;
    	}
	
		
		if (lats[3].equals("S"))
			coord.setLatitude(-(latdegree*60+latminute+latsecond/60));
		else 
			coord.setLatitude(latdegree*60+latminute+latsecond/60);
		
		if (longs[3].equals("W"))
			coord.setLongitude(-(longdegree*60+longminute+longsecond/60));
		else
			coord.setLongitude(longdegree*60+longminute+longsecond/60);

    	}
    	
    	
    	else if (longitude.contains(".") && longitude.contains("°")) // Example: 53.850833°
    	{
    		float floatlongi = Float.valueOf(longitude.substring(0, (longitude.length()-1)))*60;
	    		
    		float floatlati = Float.valueOf(latitude.substring(0, (latitude.length()-1)))*60;
    		
    		coord.setLongitude(floatlongi);
    		coord.setLatitude(floatlati);
    		
    	}
    	   	
    	
    	else if (longitude.contains(".")) // Example: 4958.2620N
    	{
    		
    		float floatlongi = Float.valueOf(longitude.substring(0, (longitude.length()-1)));
    	   		    		
    		floatlongi = floatlongi/100;
    		
    		int intlongi = (int) floatlongi;
    		
    		floatlongi = floatlongi-intlongi;
    		
    		intlongi = intlongi*60;
    		
    		floatlongi = intlongi+floatlongi*100;
    		 		
    		
    		float floatlati = Float.valueOf(latitude.substring(0, (latitude.length()-1)));
    		
    		floatlati = floatlati/100;
    		
    		int intlati = (int) floatlati;
    		
    		floatlati = floatlati-intlati;
    		
    		intlati = intlati*60;
    		
    		floatlati = intlati+floatlati*100;
    		
    		
    		
    		if (latitude.substring(latitude.length()) == "S")
    			coord.setLatitude(-floatlati);
    		else
    			coord.setLatitude(floatlati);
    		
    		if (longitude.substring(longitude.length()) == "W")
    			coord.setLongitude(-floatlongi);
    		else
    			coord.setLongitude(floatlongi);
    	
    	}
    	
    	   	
    	else
    	{
    		System.out.println("Wrong format!");
    		return null;
    	}
    	
    	//180°
    	if (coord.getLongitude() >= -10800 &&  coord.getLongitude() <= 10800 &&  coord.getLatitude() >= -10800 && coord.getLatitude() <= 10800)
    		return coord;
    	else
    	{
    		System.out.println("Coordinate out of bounds!");
    		return null;
    	}
    	}
    	catch(Exception ee)
		{}
    	
    	
    	return null;
    	
    	
    } // ConvertCoord

} // Map24MapletRemoteControl


